﻿using System.Linq;
using System.Web.DomainServices;
using System.Web.DomainServices.Providers;
using System.Web.Ria;
using SoftSource.Timecard.Web.Data;

namespace SoftSource.Timecard.Web.Services
{
    [EnableClientAccess]
    [RequiresAuthentication]
    [RequiresRole("Administrator")]
    public class MilestoneService : LinqToSqlDomainService<MilestoneDBDataContext>
    {
        public IQueryable<Milestone> GetMilestones()
        {
            return this.DataContext.Milestones;
        }

        public void InsertMilestone(Milestone milestone)
        {
            this.DataContext.Milestones.InsertOnSubmit(milestone);
        }

        public void UpdateMilestone(Milestone currentMilestone)
        {
            this.DataContext.Milestones.Attach(currentMilestone, this.ChangeSet.GetOriginal(currentMilestone));
        }

        public void DeleteMilestone(Milestone milestone)
        {            
            this.DataContext.Milestones.Attach(milestone);
            this.DataContext.Milestones.DeleteOnSubmit(milestone);
        }
    }
}


